<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root"></div>
    <script>
        var targetNode=document.getElementById('root');
        var config = {attributes:true,childList:true,subtree:true};
        var callback = function(mutationsList,observer){
            for(var mutation of mutationsList){
                if(mutation.type == 'childList'){
                    console.log('a child node has been add or remove')
                }
                else if(mutation.type=='attributes'){
                    console.log('the '+mutation.attributeName + 'attribute was modified')
                }
            }
        }
        var observer=new MutationObserver(callback);
        observer.observe(targetNode,config);
        targetNode.setAttribute('data-a','ddd')
        targetNode.appendChild(document.createElement('li'))
    </script>
</body>
</html>